package casa.depesos.app.com.dlg;

import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import casa.depesos.app.com.databinding.DlgExtendBinding;
import casa.depesos.app.com.http.data.Extend;
import casa.depesos.app.com.http.data.ExtendLink;
import casa.depesos.app.com.utils.Utils;

public class ExtendDlg extends FullScreenDlg {

    DlgExtendBinding binding;
    Extend info;
    ExtendLink link;

    public ExtendDlg setParam(Extend info, ExtendLink link) {
        this.info = info;
        this.link = link;
        return this;
    }

    @Nullable
    @Override
    public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        binding = DlgExtendBinding.inflate(inflater, container, false);
        binding.fee.setText(Utils.formatNoFloat(info.fee + "", true));
        binding.vat.setText(Utils.formatNoFloat(info.vat + "", true));
        binding.payed.setText("-" + Utils.formatNoFloat(info.indeed + "", true));
        binding.total.setText(Utils.formatNoFloat(info.remain + "", true));
        binding.tv.setOnClickListener(v -> dismiss());
        binding.tv2.setText(Utils.formatNoFloat(link.fee, true));
        return binding.getRoot();
    }
}
